package com.hys;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class NumberFrequencyCounter {
    public static void main(String[] args) {
        Map<Integer, Integer> frequencyMap = new HashMap<>();

        try (BufferedReader reader = new BufferedReader(new FileReader("C:\\Users\\Administrator\\Desktop\\files\\report_20231026105600.txt"))) {
            String line;
            while ((line = reader.readLine()) != null) {
                int number = Integer.parseInt(line.trim());
                frequencyMap.put(number, frequencyMap.getOrDefault(number, 0) + 1);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        for (Map.Entry<Integer, Integer> entry : frequencyMap.entrySet()) {
            int number = entry.getKey();
            int frequency = entry.getValue();
            System.out.println(number + " occurs " + frequency + " times");
        }
    }
}
